package org.openmore.platform.utils;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

    /**
     * @author <a href="https://github.com/binarywang">Binary Wang</a>
     */
    public class JsonUtils {
        private static final ObjectMapper JSON = new ObjectMapper();

        static {
            JSON.setSerializationInclusion(Include.NON_NULL);
            JSON.configure(SerializationFeature.INDENT_OUTPUT, Boolean.TRUE);
        }

        public static String toJson(Object obj) {
            try {
                return JSON.writeValueAsString(obj);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }

            return null;
        }
}
